﻿using Unity.VisualScripting;
using UnityEngine;

public class PlayerAirState:PlayerStateBase
{
    public PlayerAirState(ControllerBase controller, StateMachineBase stateMachine, string stateName,string 
        animatorParameter) 
        : base(controller, stateMachine, stateName,animatorParameter)
    {
    }
    
    public override void Enter()
    {
        base.Enter();
        controller.mAnimator.SetBool(Setting.jump, true); 
    }

    public override void Exit()
    {
        base.Exit();
        controller.mAnimator.SetBool(Setting.jump, false); 
    }

    public override void Update()
    {
        base.Update();

        if (controller.isWall)//贴着墙
        {
            stateMachine.ChangeState(Setting.wallSlide);
            return;
        }
        
        if (controller.isGround)//贴着地面
        {
            stateMachine.ChangeState(Setting.idle);
            return;
        }
        else
        {
            //空中移动
            controller.SetVelocity(new Vector2(SelfController.moveX*Setting.speed*0.8f, controller.GetVelocity().y));
        }
    }
    
    
}